import  { App } from 'vue';
import '@/styles/index.scss';
import '@/assets/index.css'
import Message from '@/setup/message.ts'
import Spin from '@/setup/spin.ts'

// base
import CkButton from "@/components/Base/Button/index"; // 按钮
import CkButtonGroup from "@/components/Base/Button/group"; // 按钮组
import CkIcon from "@/components/Base/Icon/index"; // 图标
import CkWatermark from "@/components/Base/Watermark"; // 水印
// form

import CkInput from "@/components/Form/Input"; // 输入框
import CkSwitch from "@/components/Form/Switch"; // 开关
// layout
import CkCard from "@/components/Layout/Card/index"; // 卡片
import CkSplitPane from "@/components/Layout/SplitPane/index"; // 分割面板
// view
import CkSpin from "@/components/View/Spin/index"; // 加载
import CkAlert from "@/components/View/Alert/index"; // 提示
import CkModal from "@/components/View/Modal"; // 弹窗
import CkTooltip from "@/components/View/Tooltip"; // 提示
import CkDrawer from "@/components/View/Drawer"; // 抽屉
import CkMessage from "@/components/View/Message"; // 消息
import CkCarousel from "@/components/View/Carousel"; // 轮播
import { CkImage, CkImageViewer , CkImageGroup     } from "@/components/View/Image"; // 图片
import { CkMarquee } from "@/components/View/Marquee"; // 走马灯
import { CkScrollbar } from "@/components/View/Scrollbar"; // 滚动条
import CkTable from "@/components/View/Table"; // 表格
import { CkTimePicker } from "@/components/View/TimePicker"; // 时间范围
import CkTimeline from "@/components/View/Timeline"; // 时间线

let components = [
  CkButton,
  CkButtonGroup,
  CkIcon,
  CkCard,
  CkSwitch,
  CkSpin,
  CkSplitPane,
  CkInput,
  CkAlert,
  CkModal,
  CkTooltip,
  CkDrawer,
  CkMessage,
  CkCarousel,
  CkImage,
  CkImageViewer , 
  CkImageGroup,
  CkMarquee,
  CkScrollbar,
  CkTable,
  CkTimePicker,
  CkTimeline,
  CkWatermark
]


// base
export { default as CkButton}  from "@/components/Base/Button";
export { default as CkButtonGroup}  from "@/components/Base/Button/group";
export { default as CkIcon}  from "@/components/Base/Icon";
export { default as CkWatermark}  from "@/components/Base/Watermark";
// form

export { default as CkInput}  from "@/components/Form/Input";
export { default as CkSwitch}  from "@/components/Form/Switch";
// layout
export { default as CkCard}  from "@/components/Layout/Card";
export { default as CkSplitPane}  from "@/components/Layout/SplitPane";
// view
export { default as CkSpin}  from "@/components/View/Spin";
export { default as CkAlert}  from "@/components/View/Alert";
export { default as CkModal}  from "@/components/View/Modal";
export { default as CkTooltip}  from "@/components/View/Tooltip";
export { default as CkDrawer}  from "@/components/View/Drawer";
export { default as CkMessage}  from "@/components/View/Message";
export { default as CkCarousel}  from "@/components/View/Carousel";
export { CkImage, CkImageViewer, CkImageGroup,}  from "@/components/View/Image";
export { CkMarquee }  from "@/components/View/Marquee";
export { CkScrollbar}  from "@/components/View/Scrollbar";
export { default as CkTable}  from "@/components/View/Table";
export { CkTimePicker }  from "@/components/View/TimePicker";
export { default as CkTimeline}  from "@/components/View/Timeline";

// 保留原有的install函数和默认导出（必须保留）
const install = (Vue: App) => {
  components.map((component: any) => {
    console.log(component.__name, '__name');
    
    Vue.component(component.__name as string, component)
      // Support global import
      Vue.config.globalProperties.$Message = Message
      Vue.config.globalProperties.$Spin = Spin
      // Vue.config.globalProperties.$setLocale = setLocale
  })
}

// 保留全局环境自动安装逻辑
let windowObj = window as any
if (typeof windowObj !== 'undefined' && windowObj.Vue) {
    const vm = windowObj.Vue.createApp({})
    install(vm)
}



// Auto import css
if (typeof window !== 'undefined') {
    // import('../dist/view-shadcn-ui.min.css')
}

// 导出安装函数（兼容旧方式）
export default install